package com.tensquare.friend.dao;

import com.tensquare.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface FriendDao extends JpaRepository<Friend,String> {

    //通过用户id和好友id查询一条数据
    public Friend findByUseridAndFriendid(String userid,String friendid);

    //修改islike状态 通过用户id和好友id
    @Modifying
    @Query(value = "UPDATE tb_friend SET islike=? where userid=? and friendid=?",nativeQuery = true)
    public void updateIslike(String islike,String userid,String friendid);

    //删除
    @Modifying
    @Query(value = "DELETE FROM tb_friend WHERE userid=? and friendid=?",nativeQuery = true)
    public void deleteFriend(String userid,String friendid);
}
